<template>
	<view class="content">
		<view class="bgc">
			<view class="score-box-border">
				<view class="score-box">
					<view class="score-title">本次总得分</view>
					<view class="score-content">{{trainScore}}</view>
				</view>
			</view>
		</view>
		<view class="defeat">
			<view class="defeat-title">您本次的训练成果打败了</view>
			<view class="defeat-score">{{percent}}</view>
			<view class="defeat-type">同类型患者</view>
		</view>
		<view class="btn-box">
			<view @click="uniShare" class="btn-box">
				<bigBtnL :btnBoxWidth="btnBoxWidthL" :btnBoxHeight="btnBoxHeightL" :btnColor="btnColorL"
					:btnImgSrc="btnImgSrcL" :btnText="btnTextL" :btnTextColor="btnTextColorL"
					:btnTextSize="btnTextSizeL" :btnImgWidth="btnImgWidthL" :btnRadius="btnRadiusL">
				</bigBtnl>
			</view>
			<view @click="jump" class="btn-box">
				<bigBtnL :btnBoxWidth="btnBoxWidthR" :btnBoxHeight="btnBoxHeightR" :btnColor="btnColorR"
					:btnImgSrc="btnImgSrcR" :btnText="btnTextR" :btnTextColor="btnTextColorR"
					:btnTextSize="btnTextSizeR" :btnImgWidth="btnImgWidthR" :btnRadius="btnRadiusR">
				</bigBtnL>
			</view>
		</view>
	</view>
</template>

<script>
	import bigBtnL from '@/components/bigButtonLeft.vue';
	import UniShare from '@/components/uni-share/js_sdk/uni-share.js';
	const uniShare = new UniShare();
	export default {
		onBackPress({
			from
		}) {
			console.log(from);
			if (from == 'backbutton') {
				this.$nextTick(function() {
					uniShare.hide()
				})
				return uniShare.isShow;
			}
		},
		components: {
			bigBtnL
		},
		data() {
			return {
				btnBoxWidthL: 300,
				btnBoxHeightL: 120,
				btnColorL: "#3FB8D9",
				btnImgSrcL: "../../../static/icon/training/share.png",
				btnTextL: "分享视频",
				btnTextColorL: "#ffffff",
				btnTextSizeL: 20,
				btnImgWidthL: 50,
				btnRadiusL: 50,

				btnBoxWidthR: 300,
				btnBoxHeightR: 120,
				btnColorR: "#FF6B3D",
				btnImgSrcR: "../../../static/icon/training/home.png",
				btnTextR: "返回首页",
				btnTextColorR: "#ffffff",
				btnTextSizeR: 20,
				btnImgWidthR: 50,
				btnRadiusR: 50,

				trainScore: 0,
				percent: ""
			}
		},
		onLoad() {
			plus.screen.lockOrientation('portrait-primary');
			this.getRank();
		},
		methods: {
			jump() {
				uni.switchTab({
					url: '../../tabBar/training/training'
				})
			},
			getRank() {
				var me = this;
				var usertoken = uni.getStorageSync("usertoken");
				var info = uni.getStorageSync("accountInfo");
				uni.request({
					url: me.serverUrl + "/train/getTrainResult",
					data: {
						"openid": info.openid
					},
					method: "POST",
					header: {
						"usertoken": usertoken
					},
					success(res) {
						console.log(res.data)
						if (res.data.status == 200) {
							me.trainScore = res.data.trainScore;
							me.percent = res.data.percent + '%';
						}
					}
				})
			},
			uniShare() {
				uniShare.show({
					content: { //公共的分享参数配置  类型（type）、链接（herf）、标题（title）、summary（描述）、imageUrl（缩略图）
						type: 0,
						href: 'http://www.brainseek.cn:8000/static/lookvideo/07a09af6-576d-11ec-b5ea-556b45fb49a9.mp4',
						title: '标题',
						summary: '描述',
						imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
					},
					menus: [{
							"img": "/static/app-plus/sharemenu/wechatfriend.png",
							"text": "微信好友",
							"share": { //当前项的分享参数配置。可覆盖公共的配置如下：分享到微信小程序，配置了type=5
								"provider": "weixin",
								"scene": "WXSceneSession"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/wechatmoments.png",
							"text": "微信朋友圈",
							"share": {
								"provider": "weixin",
								"scene": "WXSceneTimeline"
							}
						},
						// {
						// 	"img": "/static/app-plus/sharemenu/mp_weixin.png",
						// 	"text": "微信小程序",
						// 	"share": {
						// 		provider: "weixin",
						// 		scene: "WXSceneSession",
						// 		type: 5,
						// 		miniProgram: {
						// 			id: '123',
						// 			path: '/pages/list/detail',
						// 			webUrl: '/#/pages/list/detail',
						// 			type: 0
						// 		},
						// 	}
						// },
						// {
						// 	"img": "/static/app-plus/sharemenu/weibo.png",
						// 	"text": "微博",
						// 	"share": {
						// 		"provider": "sinaweibo"
						// 	}
						// },
						// {
						// 	"img": "/static/app-plus/sharemenu/qq.png",
						// 	"text": "QQ",
						// 	"share": {
						// 		"provider": "qq"
						// 	}
						// },
						// {
						// 	"img": "/static/app-plus/sharemenu/copyurl.png",
						// 	"text": "复制",
						// 	"share": "copyurl"
						// },
						// {
						// 	"img": "/static/app-plus/sharemenu/more.png",
						// 	"text": "更多",
						// 	"share": "shareSystem"
						// }
					],
					cancelText: "取消分享",
				}, e => { //callback
					console.log(uniShare.isShow);
					console.log(e);
				})
			}
		}
	}
</script>

<style>
	@import url("trainScore.css");
</style>
